package org.bonorsoft.modules.education.service.impl;

import lombok.extern.slf4j.Slf4j;
import org.bonorsoft.common.constant.StatisticalConstant;
import org.bonorsoft.common.system.api.ISysBaseAPI;
import org.bonorsoft.common.util.WilliamUtil;
import org.bonorsoft.common.util.oConvertUtils;
import org.bonorsoft.modules.education.entity.EduInfor;
import org.bonorsoft.modules.education.mapper.EduInforMapper;
import org.bonorsoft.modules.education.service.IEduInforService;
import org.bonorsoft.modules.statistical.entity.*;
import org.bonorsoft.modules.statistical.out.OutTotalInfo;
import org.bonorsoft.modules.statistical.util.CityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

/**
 * @Description: 全市学校信息表
 * @Author: WilliamYe
 * @Date:   2020-11-23
 * @Version: V1.0
 */
@Service
@Slf4j
public class EduInforServiceImpl extends ServiceImpl<EduInforMapper, EduInfor> implements IEduInforService {

    @Resource
    private EduInforMapper eduInforMapper;

    @Autowired
    private ISysBaseAPI sysBaseAPI;

    /** 功能描述:根据年份和学校类型统计数据(默认是2019年)
     *
     * @vison: 1.0.0
     * @Author: WilliamYe
     * @Date: 2020/11/25 16:01
     */
    @Override
    public TotalInfo getStaticInfo(Integer year, String type) {
        List<StatisticalBasicData> list;
        if(oConvertUtils.isEmpty(type)){
            //查询统计全部学段（默认2019，全部学段）
            list = eduInforMapper.getAllAgeStructure(year);
        }else{
            //根据学段类型查询统计（默认2019）
            list = eduInforMapper.getAllAgeStructureByType(year, type);
        }

        TotalInfo total = new TotalInfo();
        //各县区某年教师年龄结构
        //List<Map<String,Object>> ageStructureList = getAgeStructure(list);
        //各县区某年教师年龄结构-新的呈现方式
        //List<Map<String,Object>> ageStructure = getOtherAgeStructure(list);
        Map<String, Object> ageStructureByTen = getOtherAgeStructureByTen(list);

        //各县区教师数量
        List<Map<String,Object>> teacherNumber = getTeacherNumber(list);

        //各县区学生数量
        List<Map<String,Object>> studentNumber = getStudentNumber(list);

        //学校生数量百分比
        List<Map<String,Object>> studentPercentage = getStudentPercentage(list);

        //各县区教师学历结构
        //List<Map<String,Object>> teachersQualifications = getTeachersQualifications(list);
        //各县区教师学历结构-新的呈现方式
        Map<String, Object> teachersQualificationList = getOtherTeachersQualifications(list);

        //各县区学校数量
        List<Map<String,Object>> schoolNumber = getSchoolNumber(list);
        List<Map<String,Object>> schoolNew = getSchoolNewNumber(list);


        total.setAgeStructures(ageStructureByTen);
        total.setTeacherNumber(teacherNumber);
        total.setStudentNumber(studentNumber);
        total.setStudentPercentage(studentPercentage);
        total.setTeachersQualifications(teachersQualificationList);
        total.setSchoolNumber(schoolNumber);
        total.setNewSchoolNumber(schoolNew);


        return total;
    }

    /** 功能描述:根据年份和学校类型获取全部学校信息(默认是2019年)
     *
     * @vison: 1.0.0
     * @Author: WilliamYe
     * @Date: 2020/11/26 8:46
     */
    @Override
    public AllSchoolVo getAllInformation(Integer year, String type) {
        long start = System.currentTimeMillis();
        AllSchoolVo vo = new AllSchoolVo();
        List<EduInforVo> eduInforVoList;
        if(oConvertUtils.isEmpty(type)){
            //查询统计全部学段（默认2019，全部学段）
            eduInforVoList = eduInforMapper.getEduInforVo(year);
        }else{
            //根据学段类型查询统计（默认2019）
            eduInforVoList = eduInforMapper.getEduInforVoByType(year,type);
        }
        //学校信息
        List<Map<String, Object>> schoolInfo = getSchoolInfo(eduInforVoList);

        //获取东营区学校信息
        List<Map<String, Object>> dongYingInfor = getDongYingInfor(eduInforVoList);

        //获取河口学校信息
        List<Map<String, Object>> heKouInfor = getHeKouInfor(eduInforVoList);

        //获取垦利学校信息
        List<Map<String, Object>> kenLiInfor = getKenLiInfor(eduInforVoList);

        //获取利津学校信息
        List<Map<String, Object>> liJInInfor = getLiJinInfor(eduInforVoList);

        //获取广饶学校信息
        List<Map<String, Object>> guangRaoInfor = getGuangRaoInfor(eduInforVoList);

        //获取经济开发区学校信息
        List<Map<String, Object>> jingJiInfor = getJingJiInfor(eduInforVoList);

        //获取农高学校信息
        List<Map<String, Object>> nongGaoInfor = getNongGaoInfor(eduInforVoList);


        log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");

        vo.setAllSchoolInformation(schoolInfo);
        vo.setDongYingInformation(dongYingInfor);
        vo.setHeKouInformation(heKouInfor);
        vo.setKenLIInformation(kenLiInfor);
        vo.setLiJInInformation(liJInInfor);
        vo.setGuangRaoInformation(guangRaoInfor);
        vo.setJingJiInformation(jingJiInfor);
        vo.setNongGaoInformation(nongGaoInfor);
        return vo;
    }

    /** 功能描述:全市各学科教师数量
     *
     * @vison: 1.0.0
     * @Author: WilliamYe
     * @Date: 2020/11/26 14:40
     */
    @Override
    public List<Map<String, Object>> getSubjectTeachers(Integer year, String type) {
        SubjectVo subject;
        if(oConvertUtils.isEmpty(type)){
            //查询统计全部学段（默认2019，全部学段）
            subject = eduInforMapper.getSubjectTeachers(year);
        }else{
            //根据学段类型查询统计（默认2019）
            subject = eduInforMapper.getSubjectTeachersByType(year,type);
        }
        ArrayList arrayList = WilliamUtil.ConvertObjToList(subject);
        List<Map<String, Object>> subjectTeachers = new ArrayList<>();
        int size = StatisticalConstant.ALL_SUBJECT.size();
        for (int i = 0; i < size; i++){
            Map<String, Object> map = new HashMap<>();
            map.put("学科", StatisticalConstant.ALL_SUBJECT.get(i));
            String number = "0";
            if(arrayList != null){
                number = (String) arrayList.get(i);
            }
            map.put("教师数量",number);
            subjectTeachers.add(map);
        }
        return subjectTeachers;
    }

    /** 功能描述:各县区2019年教师年龄结构
     *
     * @vison: 1.0.0
     * @Author: WilliamYe
     * @Date: 2020/11/25 15:58
     */
    private List<Map<String, Object>> getAgeStructure(List<StatisticalBasicData> list) {
        List<Map<String,Object>> agesList = new ArrayList<>();
        Map<String,Object> twentyFour = getMapByAge(StatisticalConstant.TWENTY_FOUR_YEARS);
        Map<String,Object> twentyFive = getMapByAge(StatisticalConstant.TWENTY_FIVE_YEARS);
        Map<String,Object> thirty = getMapByAge(StatisticalConstant.THIRTY_YEARS);
        Map<String,Object> thirtyFive = getMapByAge(StatisticalConstant.THIRTY_FIVE_YEARS);
        Map<String,Object> forty = getMapByAge(StatisticalConstant.FORTY_YEARS);
        Map<String,Object> fortyFive = getMapByAge(StatisticalConstant.FORTY_FIVE_YEARS);
        Map<String,Object> fifty = getMapByAge(StatisticalConstant.FIFTY_YEARS);
        Map<String,Object> fiftyFive = getMapByAge(StatisticalConstant.FIFTY_FIVE_YEARS);
        Map<String,Object> sixty = getMapByAge(StatisticalConstant.SIXTY_YEARS);
        list.forEach(item -> {
            //判断是否为三区两县
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                twentyFour.put(item.getSchoolLocationThree(),item.getTwentyFour());
                twentyFive.put(item.getSchoolLocationThree(),item.getTwentyFive());
                thirty.put(item.getSchoolLocationThree(),item.getThirty());
                thirtyFive.put(item.getSchoolLocationThree(),item.getThirtyFive());
                forty.put(item.getSchoolLocationThree(),item.getForty());
                fortyFive.put(item.getSchoolLocationThree(),item.getFortyFive());
                fifty.put(item.getSchoolLocationThree(),item.getFifty());
                fiftyFive.put(item.getSchoolLocationThree(),item.getFiftyFive());
                sixty.put(item.getSchoolLocationThree(),item.getSixty());
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                twentyFour.put(StatisticalConstant.NONG_GAO_NEW,item.getTwentyFour());
                twentyFive.put(StatisticalConstant.NONG_GAO_NEW,item.getTwentyFive());
                thirty.put(StatisticalConstant.NONG_GAO_NEW,item.getThirty());
                thirtyFive.put(StatisticalConstant.NONG_GAO_NEW,item.getThirtyFive());
                forty.put(StatisticalConstant.NONG_GAO_NEW,item.getForty());
                fortyFive.put(StatisticalConstant.NONG_GAO_NEW,item.getFortyFive());
                fifty.put(StatisticalConstant.NONG_GAO_NEW,item.getFifty());
                fiftyFive.put(StatisticalConstant.NONG_GAO_NEW,item.getFiftyFive());
                sixty.put(StatisticalConstant.NONG_GAO_NEW,item.getSixty());
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                twentyFour.put(StatisticalConstant.JING_JI_NEW,item.getTwentyFour());
                twentyFive.put(StatisticalConstant.JING_JI_NEW,item.getTwentyFive());
                thirty.put(StatisticalConstant.JING_JI_NEW,item.getThirty());
                thirtyFive.put(StatisticalConstant.JING_JI_NEW,item.getThirtyFive());
                forty.put(StatisticalConstant.JING_JI_NEW,item.getForty());
                fortyFive.put(StatisticalConstant.JING_JI_NEW,item.getFortyFive());
                fifty.put(StatisticalConstant.JING_JI_NEW,item.getFifty());
                fiftyFive.put(StatisticalConstant.JING_JI_NEW,item.getFiftyFive());
                sixty.put(StatisticalConstant.JING_JI_NEW,item.getSixty());
            }
        });
        agesList.add(twentyFour);
        agesList.add(twentyFive);
        agesList.add(thirty);
        agesList.add(thirtyFive);
        agesList.add(forty);
        agesList.add(fortyFive);
        agesList.add(fifty);
        agesList.add(fiftyFive);
        agesList.add(sixty);
        return agesList;
    }

    /**
     * 另一种形式获取各县区2019年教师年龄结构
     * @param list
     * @return
     */
    private List<Map<String, Object>> getOtherAgeStructure(List<StatisticalBasicData> list) {
        List<Map<String, Object>> ageStructureList = new ArrayList<>();
        CityUtil.sortedByProvince(list);
        list.forEach(item -> {
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.TWENTY_FOUR_YEARS,item.getTwentyFour().toString(),ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.TWENTY_FIVE_YEARS,item.getTwentyFive().toString(),ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.THIRTY_YEARS,item.getThirty().toString(),ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.THIRTY_FIVE_YEARS,item.getThirtyFive().toString(),ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.FORTY_YEARS,item.getForty().toString(),ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.FORTY_FIVE_YEARS,item.getFortyFive().toString(),ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.FIFTY_YEARS,item.getFifty().toString(),ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.FIFTY_FIVE_YEARS,item.getFiftyFive().toString(),ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.SIXTY_YEARS,item.getSixty().toString(),ageStructureList);
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.TWENTY_FOUR_YEARS,item.getTwentyFour().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.TWENTY_FIVE_YEARS,item.getTwentyFive().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.THIRTY_YEARS,item.getThirty().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.THIRTY_FIVE_YEARS,item.getThirtyFive().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.FORTY_YEARS,item.getForty().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.FORTY_FIVE_YEARS,item.getFortyFive().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.FIFTY_YEARS,item.getFifty().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.FIFTY_FIVE_YEARS,item.getFiftyFive().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.SIXTY_YEARS,item.getSixty().toString(),ageStructureList);
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.TWENTY_FOUR_YEARS,item.getTwentyFour().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.TWENTY_FIVE_YEARS,item.getTwentyFive().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.THIRTY_YEARS,item.getThirty().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.THIRTY_FIVE_YEARS,item.getThirtyFive().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.FORTY_YEARS,item.getForty().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.FORTY_FIVE_YEARS,item.getFortyFive().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.FIFTY_YEARS,item.getFifty().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.FIFTY_FIVE_YEARS,item.getFiftyFive().toString(),ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.SIXTY_YEARS,item.getSixty().toString(),ageStructureList);
            }
        });
        return ageStructureList;
    }

    /**
     * 另一种形式获取各县区教师年龄结构(10年一跨度)
     * @param list
     * @return
     */
    private Map<String, Object> getOtherAgeStructureByTen(List<StatisticalBasicData> list) {
        List<Map<String, Object>> ageStructureList = new ArrayList<>();
        List<Map<String, Object>> ageStructureRatio = new ArrayList<>();
        CityUtil.sortedByProvince(list);
        list.forEach(item -> {
            Integer thirtyYearsBelow = item.getTwentyFour() + item.getTwentyFive();
            Integer thirtyFortyYears = item.getThirty() + item.getThirtyFive();
            Integer fortyFiftyYears = item.getForty() + item.getFortyFive();
            Integer fiftySixtyYears = item.getFifty() + item.getFiftyFive() + item.getSixty();
            Integer total = thirtyYearsBelow + thirtyFortyYears + fortyFiftyYears + fiftySixtyYears;
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.THIRTY_YEARS_BELOW, thirtyYearsBelow.toString(), ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.THIRTY_FORTY_YEARS, thirtyFortyYears.toString(), ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.FORTY_FIFTY_YEARS, fortyFiftyYears.toString(), ageStructureList);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.FIFTY_SIXTY_YEARS, fiftySixtyYears.toString(), ageStructureList);

                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.THIRTY_YEARS_BELOW, WilliamUtil.getSchoolPercentage(thirtyYearsBelow,total), ageStructureRatio);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.THIRTY_FORTY_YEARS, WilliamUtil.getSchoolPercentage(thirtyFortyYears,total), ageStructureRatio);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.FORTY_FIFTY_YEARS, WilliamUtil.getSchoolPercentage(fortyFiftyYears,total), ageStructureRatio);
                setAgeStructure(item.getSchoolLocationThree(),StatisticalConstant.FIFTY_SIXTY_YEARS, WilliamUtil.getSchoolPercentage(fiftySixtyYears,total), ageStructureRatio);
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.THIRTY_YEARS_BELOW, thirtyYearsBelow.toString(), ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.THIRTY_FORTY_YEARS, thirtyFortyYears.toString(), ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.FORTY_FIFTY_YEARS, fortyFiftyYears.toString(), ageStructureList);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.FIFTY_SIXTY_YEARS, fiftySixtyYears.toString(), ageStructureList);

                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.THIRTY_YEARS_BELOW, WilliamUtil.getSchoolPercentage(thirtyYearsBelow,total), ageStructureRatio);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.THIRTY_FORTY_YEARS, WilliamUtil.getSchoolPercentage(thirtyFortyYears,total), ageStructureRatio);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.FORTY_FIFTY_YEARS, WilliamUtil.getSchoolPercentage(fortyFiftyYears,total), ageStructureRatio);
                setAgeStructure(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.FIFTY_SIXTY_YEARS, WilliamUtil.getSchoolPercentage(fiftySixtyYears,total), ageStructureRatio);
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.THIRTY_YEARS_BELOW, thirtyYearsBelow.toString(), ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.THIRTY_FORTY_YEARS, thirtyFortyYears.toString(), ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.FORTY_FIFTY_YEARS, fortyFiftyYears.toString(), ageStructureList);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.FIFTY_SIXTY_YEARS, fiftySixtyYears.toString(), ageStructureList);

                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.THIRTY_YEARS_BELOW, WilliamUtil.getSchoolPercentage(thirtyYearsBelow,total), ageStructureRatio);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.THIRTY_FORTY_YEARS, WilliamUtil.getSchoolPercentage(thirtyFortyYears,total), ageStructureRatio);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.FORTY_FIFTY_YEARS, WilliamUtil.getSchoolPercentage(fortyFiftyYears,total), ageStructureRatio);
                setAgeStructure(StatisticalConstant.JING_JI_NEW,StatisticalConstant.FIFTY_SIXTY_YEARS, WilliamUtil.getSchoolPercentage(fiftySixtyYears,total), ageStructureRatio);
            }
        });
        Map<String, Object> all = new HashMap<>();
        all.put("年龄段", ageStructureList);
        all.put("百分比", ageStructureRatio);
        return all;
    }

    /**
     * 定义年龄结构数据
     */
    private void setAgeStructure(String location, String age, String number, List<Map<String, Object>> list){
        Map<String, Object> map = new HashMap<>();
        map.put("一级地点", location);
        map.put("年龄段",age);
        map.put("数量",number);
        list.add(map);
    }

    /**
     * 各县区2019教师数量
     * @param list
     * @return
     */
    private List<Map<String, Object>> getTeacherNumber(List<StatisticalBasicData> list) {
        List<Map<String, Object>> teacherList = new ArrayList<>();
        CityUtil.sortedByProvince(list);
        list.forEach(item -> {
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                Map<String, Object> map = new HashMap<>();
                map.put("一级地点", item.getSchoolLocationThree());
                map.put("教师数量",item.getTotalStaff());
                teacherList.add(map);
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                Map<String, Object> map = new HashMap<>();
                map.put("一级地点", StatisticalConstant.NONG_GAO_NEW);
                map.put("教师数量",item.getTotalStaff());
                teacherList.add(map);
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                Map<String, Object> map = new HashMap<>();
                map.put("一级地点", StatisticalConstant.JING_JI_NEW);
                map.put("教师数量",item.getTotalStaff());
                teacherList.add(map);
            }
        });

        return teacherList;
    }

    /**
     * 各县区2019学生数量
     * @param list
     * @return
     */
    private List<Map<String, Object>> getStudentNumber(List<StatisticalBasicData> list) {
        List<Map<String, Object>> studentList = new ArrayList<>();
        list.forEach(item -> {
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                Map<String, Object> map = new HashMap<>();
                map.put("一级地点", item.getSchoolLocationThree());
                map.put("学生数量",item.getTotalStudent());
                studentList.add(map);
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                Map<String, Object> map = new HashMap<>();
                map.put("一级地点", StatisticalConstant.NONG_GAO_NEW);
                map.put("学生数量",item.getTotalStudent());
                studentList.add(map);
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                Map<String, Object> map = new HashMap<>();
                map.put("一级地点", StatisticalConstant.JING_JI_NEW);
                map.put("学生数量",item.getTotalStudent());
                studentList.add(map);
            }
        });

        return studentList;
    }

    /**
     * 学校生数量百分比
     * @param list
     * @return
     */
    private List<Map<String, Object>> getStudentPercentage(List<StatisticalBasicData> list) {
        List<Map<String, Object>> percentageList = new ArrayList<>();
        final Integer[] total = {0};
        list.forEach(item -> total[0] += item.getTotalStudent());
        Map<String, Object> map = new HashMap<>();
        list.forEach(item ->{
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                map.put(item.getSchoolLocationThree(), WilliamUtil.getSchoolPercentage(item.getTotalStudent(),total[0]));
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                map.put(StatisticalConstant.NONG_GAO_NEW, WilliamUtil.getSchoolPercentage(item.getTotalStudent(),total[0]));
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                map.put(StatisticalConstant.JING_JI_NEW, WilliamUtil.getSchoolPercentage(item.getTotalStudent(),total[0]));
            }
        });
        percentageList.add(map);
        return percentageList;
    }

    /**
     * 各县区教师学历结构
     * @param list
     * @return
     */
    private List<Map<String, Object>> getTeachersQualifications(List<StatisticalBasicData> list) {
        List<Map<String,Object>> qualifications = new ArrayList<>();
        Map<String,Object> graduateStaff = getMapByQua(StatisticalConstant.GRADUATE_DEGREE_STAFF);
        Map<String,Object> bachelorStaff = getMapByQua(StatisticalConstant.BACHELOR_DEGREE_STAFF);
        Map<String,Object> juniorStaff = getMapByQua(StatisticalConstant.JUNIOR_COLLEGE_DEGREE_STAFF);
        Map<String,Object> highStaff = getMapByQua(StatisticalConstant.HIGH_SCHOOL_EDUCATION_STAFF);
        Map<String,Object> belowStaff = getMapByQua(StatisticalConstant.BELOW_HIGH_SCHOOL_STAFF);

        list.forEach(item -> {
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                belowStaff.put(item.getSchoolLocationThree(),item.getBelowStaff());
                highStaff.put(item.getSchoolLocationThree(),item.getHighStaff());
                juniorStaff.put(item.getSchoolLocationThree(),item.getJuniorStaff());
                bachelorStaff.put(item.getSchoolLocationThree(),item.getBachelorStaff());
                graduateStaff.put(item.getSchoolLocationThree(),item.getGraduateStaff());
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                belowStaff.put(StatisticalConstant.NONG_GAO_NEW,item.getBelowStaff());
                highStaff.put(StatisticalConstant.NONG_GAO_NEW,item.getHighStaff());
                juniorStaff.put(StatisticalConstant.NONG_GAO_NEW,item.getJuniorStaff());
                bachelorStaff.put(StatisticalConstant.NONG_GAO_NEW,item.getBachelorStaff());
                graduateStaff.put(StatisticalConstant.NONG_GAO_NEW,item.getGraduateStaff());
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                belowStaff.put(StatisticalConstant.JING_JI_NEW,item.getBelowStaff());
                highStaff.put(StatisticalConstant.JING_JI_NEW,item.getHighStaff());
                juniorStaff.put(StatisticalConstant.JING_JI_NEW,item.getJuniorStaff());
                bachelorStaff.put(StatisticalConstant.JING_JI_NEW,item.getBachelorStaff());
                graduateStaff.put(StatisticalConstant.JING_JI_NEW,item.getGraduateStaff());
            }
        });
        qualifications.add(graduateStaff);
        qualifications.add(bachelorStaff);
        qualifications.add(juniorStaff);
        qualifications.add(highStaff);
        qualifications.add(belowStaff);
        return qualifications;
    }

    /**
     * 各县区教师学历结构-另一种展现形式
     * @param list
     * @return
     */
    private Map<String, Object> getOtherTeachersQualifications(List<StatisticalBasicData> list) {
        List<Map<String, Object>> qualificationStructureList = new ArrayList<>();
        List<Map<String, Object>> qualificationStructureRatio = new ArrayList<>();
        CityUtil.sortedByProvince(list);
        list.forEach(item -> {
            Integer total = item.getGraduateStaff() + item.getBachelorStaff() + item.getJuniorStaff() + item.getHighStaff() + item.getBelowStaff();
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.GRADUATE_DEGREE_STAFF,item.getGraduateStaff().toString(),qualificationStructureList);
                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.BACHELOR_DEGREE_STAFF,item.getBachelorStaff().toString(),qualificationStructureList);
                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.JUNIOR_COLLEGE_DEGREE_STAFF,item.getJuniorStaff().toString(),qualificationStructureList);
                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.HIGH_SCHOOL_EDUCATION_STAFF,item.getHighStaff().toString(),qualificationStructureList);
                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.BELOW_HIGH_SCHOOL_STAFF,item.getBelowStaff().toString(),qualificationStructureList);

                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.GRADUATE_DEGREE_STAFF,WilliamUtil.getSchoolPercentage(item.getGraduateStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.BACHELOR_DEGREE_STAFF,WilliamUtil.getSchoolPercentage(item.getBachelorStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.JUNIOR_COLLEGE_DEGREE_STAFF,WilliamUtil.getSchoolPercentage(item.getJuniorStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.HIGH_SCHOOL_EDUCATION_STAFF,WilliamUtil.getSchoolPercentage(item.getHighStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(item.getSchoolLocationThree(),StatisticalConstant.BELOW_HIGH_SCHOOL_STAFF,WilliamUtil.getSchoolPercentage(item.getBelowStaff(),total),qualificationStructureRatio);
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.GRADUATE_DEGREE_STAFF,item.getGraduateStaff().toString(),qualificationStructureList);
                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.BACHELOR_DEGREE_STAFF,item.getBachelorStaff().toString(),qualificationStructureList);
                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.JUNIOR_COLLEGE_DEGREE_STAFF,item.getJuniorStaff().toString(),qualificationStructureList);
                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.HIGH_SCHOOL_EDUCATION_STAFF,item.getHighStaff().toString(),qualificationStructureList);
                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.BELOW_HIGH_SCHOOL_STAFF,item.getBelowStaff().toString(),qualificationStructureList);

                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.GRADUATE_DEGREE_STAFF,WilliamUtil.getSchoolPercentage(item.getGraduateStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.BACHELOR_DEGREE_STAFF,WilliamUtil.getSchoolPercentage(item.getBachelorStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.JUNIOR_COLLEGE_DEGREE_STAFF,WilliamUtil.getSchoolPercentage(item.getJuniorStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.HIGH_SCHOOL_EDUCATION_STAFF,WilliamUtil.getSchoolPercentage(item.getHighStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(StatisticalConstant.NONG_GAO_NEW,StatisticalConstant.BELOW_HIGH_SCHOOL_STAFF,WilliamUtil.getSchoolPercentage(item.getBelowStaff(),total),qualificationStructureRatio);
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.GRADUATE_DEGREE_STAFF,item.getGraduateStaff().toString(),qualificationStructureList);
                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.BACHELOR_DEGREE_STAFF,item.getBachelorStaff().toString(),qualificationStructureList);
                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.JUNIOR_COLLEGE_DEGREE_STAFF,item.getJuniorStaff().toString(),qualificationStructureList);
                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.HIGH_SCHOOL_EDUCATION_STAFF,item.getHighStaff().toString(),qualificationStructureList);
                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.BELOW_HIGH_SCHOOL_STAFF,item.getBelowStaff().toString(),qualificationStructureList);

                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.GRADUATE_DEGREE_STAFF,WilliamUtil.getSchoolPercentage(item.getGraduateStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.BACHELOR_DEGREE_STAFF,WilliamUtil.getSchoolPercentage(item.getBachelorStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.JUNIOR_COLLEGE_DEGREE_STAFF,WilliamUtil.getSchoolPercentage(item.getJuniorStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.HIGH_SCHOOL_EDUCATION_STAFF,WilliamUtil.getSchoolPercentage(item.getHighStaff(),total),qualificationStructureRatio);
                setTeachersQualifications(StatisticalConstant.JING_JI_NEW,StatisticalConstant.BELOW_HIGH_SCHOOL_STAFF,WilliamUtil.getSchoolPercentage(item.getBelowStaff(),total),qualificationStructureRatio);
            }
        });

        Map<String, Object> all = new HashMap<>();
        all.put("学历", qualificationStructureList);
        all.put("百分比", qualificationStructureRatio);
        return all;
    }

    /**
     * 定义学历结构
     * @param location
     * @param qualification
     * @param number
     * @param list
     */
    private void setTeachersQualifications(String location, String qualification, String number, List<Map<String, Object>> list) {
        Map<String, Object> map = new HashMap<>();
        map.put("一级地点", location);
        map.put("学历",qualification);
        map.put("数量",number);
        list.add(map);
    }

    /**
     * 各县区学校数量
     * @param list
     * @return
     */
    private List<Map<String, Object>> getSchoolNumber(List<StatisticalBasicData> list) {
        List<Map<String, Object>> schoolList = new ArrayList<>();
        list.forEach(item -> {
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                Map<String, Object> map = new HashMap<>();
                map.put("一级地点", item.getSchoolLocationThree());
                map.put("学校数量",item.getSchoolNumber());
                schoolList.add(map);
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                Map<String, Object> map = new HashMap<>();
                map.put("一级地点", StatisticalConstant.NONG_GAO_NEW);
                map.put("学校数量",item.getSchoolNumber());
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                Map<String, Object> map = new HashMap<>();
                map.put("一级地点", StatisticalConstant.NONG_GAO_NEW);
                map.put("学校数量",item.getSchoolNumber());
                schoolList.add(map);
            }
        });

        return schoolList;
    }

    /**
     * 各县区学校数量-另一种展现形式
     * @param list
     * @return
     */
    private List<Map<String, Object>> getSchoolNewNumber(List<StatisticalBasicData> list) {
        List<Map<String, Object>> schoolList = new ArrayList<>();
        Map<String, Object> map = new HashMap<>();
        list.forEach(item ->{
            if(WilliamUtil.isCounties(item.getSchoolLocationThree())){
                map.put(item.getSchoolLocationThree(), item.getSchoolNumber());
            }else if(StatisticalConstant.NONG_GAO.equals(item.getSchoolLocationThree())){
                map.put(StatisticalConstant.NONG_GAO_NEW, item.getSchoolNumber());
            }else if(StatisticalConstant.JING_JI.equals(item.getSchoolLocationThree())){
                map.put(StatisticalConstant.JING_JI_NEW, item.getSchoolNumber());
            }
        });
        schoolList.add(map);
        return  schoolList;
    }

    /**
     * 学校信息
     * @param eduInforVoList
     * @return
     */
    private List<Map<String, Object>> getSchoolInfo(List<EduInforVo> eduInforVoList) {
        List<Map<String,Object>> schoolInfo = new ArrayList<>();
        eduInforVoList.forEach(item -> {
            if(oConvertUtils.isNotEmpty(item.getLongitudeX()) && item.getSchoolLocationTwo().equals(StatisticalConstant.DONG_YING_SHI)){
                setSchoolInfo(schoolInfo,item);
            }
        });
        return schoolInfo;
    }

    /** 功能描述:获取东营区学校信息
     *
     * @vison: 1.0.0
     * @Author: WilliamYe
     * @Date: 2020/11/27 16:00
     */
    private List<Map<String, Object>> getDongYingInfor(List<EduInforVo> eduInforVoList) {
        List<Map<String,Object>> schoolInfo = new ArrayList<>();
        eduInforVoList.forEach(item -> {
            if(oConvertUtils.isNotEmpty(item.getLongitudeX())
                    && item.getSchoolLocationThree().equals(StatisticalConstant.DONG_YING)
                    && item.getSchoolLocationTwo().equals(StatisticalConstant.DONG_YING_SHI)){
                setSchoolInfo(schoolInfo,item);
            }
        });
        return schoolInfo;
    }

    /**
     * 获取河口学校信息
     * @param eduInforVoList
     * @return
     */
    private List<Map<String, Object>> getHeKouInfor(List<EduInforVo> eduInforVoList) {
        List<Map<String,Object>> schoolInfo = new ArrayList<>();
        eduInforVoList.forEach(item -> {
            if(oConvertUtils.isNotEmpty(item.getLongitudeX())
                    && item.getSchoolLocationThree().equals(StatisticalConstant.HE_KOU)
                    && item.getSchoolLocationTwo().equals(StatisticalConstant.DONG_YING_SHI)){
                setSchoolInfo(schoolInfo,item);
            }
        });
        return schoolInfo;
    }

    /**
     * 获取垦利学校信息
     * @param eduInforVoList
     * @return
     */
    private List<Map<String, Object>> getKenLiInfor(List<EduInforVo> eduInforVoList) {
        List<Map<String,Object>> schoolInfo = new ArrayList<>();
        eduInforVoList.forEach(item -> {
            if(oConvertUtils.isNotEmpty(item.getLongitudeX())
                    && item.getSchoolLocationThree().equals(StatisticalConstant.KEN_LI)
                    && item.getSchoolLocationTwo().equals(StatisticalConstant.DONG_YING_SHI)){
                setSchoolInfo(schoolInfo,item);
            }
        });
        return schoolInfo;
    }

    /**
     * 获取利津学校信息
     * @param eduInforVoList
     * @return
     */
    private List<Map<String, Object>> getLiJinInfor(List<EduInforVo> eduInforVoList) {
        List<Map<String,Object>> schoolInfo = new ArrayList<>();
        eduInforVoList.forEach(item -> {
            if(oConvertUtils.isNotEmpty(item.getLongitudeX())
                    && item.getSchoolLocationThree().equals(StatisticalConstant.LI_JIN)
                    && item.getSchoolLocationTwo().equals(StatisticalConstant.DONG_YING_SHI)){
                setSchoolInfo(schoolInfo,item);
            }
        });
        return schoolInfo;
    }

    /**
     * 获取广饶学校信息
     * @param eduInforVoList
     * @return
     */
    private List<Map<String, Object>> getGuangRaoInfor(List<EduInforVo> eduInforVoList) {
        List<Map<String,Object>> schoolInfo = new ArrayList<>();
        eduInforVoList.forEach(item -> {
            if(oConvertUtils.isNotEmpty(item.getLongitudeX())
                    && item.getSchoolLocationThree().equals(StatisticalConstant.GUANG_RAO)
                    && item.getSchoolLocationTwo().equals(StatisticalConstant.DONG_YING_SHI)){
                setSchoolInfo(schoolInfo,item);
            }
        });
        return schoolInfo;
    }

    /**
     * 获取经济开发区学校信息
     * @param eduInforVoList
     * @return
     */
    private List<Map<String, Object>> getJingJiInfor(List<EduInforVo> eduInforVoList) {
        List<Map<String,Object>> schoolInfo = new ArrayList<>();
        eduInforVoList.forEach(item -> {
            if(oConvertUtils.isNotEmpty(item.getLongitudeX())
                    && item.getSchoolLocationThree().equals(StatisticalConstant.JING_JI)
                    && item.getSchoolLocationTwo().equals(StatisticalConstant.DONG_YING_SHI)){
                setSchoolInfo(schoolInfo,item);
            }
        });
        return schoolInfo;
    }

    /**
     * 获取农高学校信息
     * @param eduInforVoList
     * @return
     */
    private List<Map<String, Object>> getNongGaoInfor(List<EduInforVo> eduInforVoList) {
        List<Map<String,Object>> schoolInfo = new ArrayList<>();
        eduInforVoList.forEach(item -> {
            if(oConvertUtils.isNotEmpty(item.getLongitudeX())
                    && item.getSchoolLocationThree().equals(StatisticalConstant.NONG_GAO)
                    && item.getSchoolLocationTwo().equals(StatisticalConstant.DONG_YING_SHI)){
                setSchoolInfo(schoolInfo,item);
            }
        });
        return schoolInfo;
    }

    /**
     * 设置学校信息
     * @param schoolInfo
     * @param item
     */
    private void setSchoolInfo(List<Map<String, Object>> schoolInfo, EduInforVo item) {
        Map<String,Object> map = new HashMap<>();
        map.put("市级",item.getSchoolLocationTwo());
        map.put("县区级",item.getSchoolLocationThree());
        map.put("乡镇级",item.getSchoolLocationFour());
        map.put("村级",item.getSchoolLocationFive());
        map.put("学校名称", item.getSchoolName());
        map.put("学校经纬度", item.getLongitudeX() + "," + item.getLongitudeY());
        map.put("办学类型", getSchoolType(item.getSchoolType()));
        map.put("学校地址", item.getSchoolAddress());
        map.put("占地面积", item.getTotalAreaSchool());
        map.put("教职工数", item.getTotalNumberStaff());
        map.put("学生数", item.getTotalStudent());
        schoolInfo.add(map);
    }

    /** 功能描述:近5年各县区学生/学校数量变化
     *
     * @vison: 1.0.0
     * @Author: WilliamYe
     * @Date: 2020/11/27 13:47
     */
    @Override
    public FiveSchoolVo getFiveStudent(String type) {
        List<FiveStudentVo> list;
        if(oConvertUtils.isEmpty(type)){
            //查询统计全部学段（默认2019，全部学段）
            list = eduInforMapper.getAllFiveStudent();
        }else{
            //根据学段类型查询统计（默认2019）
            list = eduInforMapper.getAllFiveStudentByType(type);
        }
        List<Map<String,Object>> fiveStudents = new ArrayList<>();
        List<Map<String,Object>> fiveSchools = new ArrayList<>();
        int end = list.size();
        int start = end - 5;
        for(int i = start; i < end; i++){
            Integer year = list.get(i).getStatisticalYear();
            Map<String,Object> map = new HashMap<>();
            map.put("年份",year + "年");
            list.forEach(item -> {
                if(item.getStatisticalYear().equals(year)){
                    map.put(item.getCounty(),item.getInSchoolNumber());
                }
            });
            fiveStudents.add(map);

            Map<String,Object> school = new HashMap<>();
            school.put("年份",year + "年");
            list.forEach(item -> {
                if(item.getStatisticalYear().equals(year)){
                    school.put(item.getCounty(),item.getSchoolNumber());
                }
            });
            fiveSchools.add(school);
        }

        FiveSchoolVo vo = new FiveSchoolVo();
        vo.setSchoolNumber(fiveSchools);
        vo.setStudentNumber(fiveStudents);
        return vo;
    }

    /**
     * 各县区师生比
     * @param year
     * @return
     */
    @Override
    public Map<String, Object> getTeacherStudentRatio(Integer year) {
        List<TeacherStudentRatioVo> teacherStudentRatioVoLists = eduInforMapper.getTeacherStudentRatio(year);

        List<Map<String,Object>> dongPrimaryRatioLists = new ArrayList<>();
        List<Map<String,Object>> dongJuniorRatioLists = new ArrayList<>();
        List<Map<String,Object>> dongHighRatioLists = new ArrayList<>();
        List<Map<String,Object>> liPrimaryRatioLists = new ArrayList<>();
        List<Map<String,Object>> liJuniorRatioLists = new ArrayList<>();
        List<Map<String,Object>> liHighRatioLists = new ArrayList<>();
        List<Map<String,Object>> kenPrimaryRatioLists = new ArrayList<>();
        List<Map<String,Object>> kenJuniorRatioLists = new ArrayList<>();
        List<Map<String,Object>> kenHighRatioLists = new ArrayList<>();
        List<Map<String,Object>> guangPrimaryRatioLists = new ArrayList<>();
        List<Map<String,Object>> guangJuniorRatioLists = new ArrayList<>();
        List<Map<String,Object>> guangHighRatioLists = new ArrayList<>();
        List<Map<String,Object>> hePrimaryRatioLists = new ArrayList<>();
        List<Map<String,Object>> heJuniorRatioLists = new ArrayList<>();
        List<Map<String,Object>> heHighRatioLists = new ArrayList<>();
        List<Map<String,Object>> jingPrimaryRatioLists = new ArrayList<>();
        List<Map<String,Object>> jingJuniorRatioLists = new ArrayList<>();
        List<Map<String,Object>> jingHighRatioLists = new ArrayList<>();
        List<Map<String,Object>> nongPrimaryRatioLists = new ArrayList<>();
        List<Map<String,Object>> nongJuniorRatioLists = new ArrayList<>();
        List<Map<String,Object>> nongHighRatioLists = new ArrayList<>();
        List<Map<String,Object>> shiPrimaryRatioLists = new ArrayList<>();
        List<Map<String,Object>> shiJuniorRatioLists = new ArrayList<>();
        List<Map<String,Object>> shiHighRatioLists = new ArrayList<>();


        teacherStudentRatioVoLists.forEach(baseInfo -> {
            switch (baseInfo.getSchoolLocationThree()) {
                case StatisticalConstant.DONG_YING:
                    setCityRatios(dongPrimaryRatioLists, dongJuniorRatioLists, dongHighRatioLists, baseInfo);
                    break;
                case StatisticalConstant.LI_JIN:
                    setCityRatios(liPrimaryRatioLists, liJuniorRatioLists, liHighRatioLists, baseInfo);
                    break;
                case StatisticalConstant.KEN_LI:
                    setCityRatios(kenPrimaryRatioLists, kenJuniorRatioLists, kenHighRatioLists, baseInfo);
                    break;
                case StatisticalConstant.GUANG_RAO:
                    setCityRatios(guangPrimaryRatioLists, guangJuniorRatioLists, guangHighRatioLists, baseInfo);
                    break;
                case StatisticalConstant.HE_KOU:
                    setCityRatios(hePrimaryRatioLists, heJuniorRatioLists, heHighRatioLists, baseInfo);
                    break;
                case StatisticalConstant.JING_JI:
                    setCityRatios(jingPrimaryRatioLists, jingJuniorRatioLists, jingHighRatioLists, baseInfo);
                    break;
                case StatisticalConstant.NONG_GAO:
                    setCityRatios(nongPrimaryRatioLists, nongJuniorRatioLists, nongHighRatioLists, baseInfo);
                    break;
                case StatisticalConstant.SHI_ZHI:
                    setCityRatios(shiPrimaryRatioLists, shiJuniorRatioLists, shiHighRatioLists, baseInfo);
                    break;
            }
        });

        Map<String,Object> AllRatios = new HashMap<>();
        setSchoolRatios(StatisticalConstant.DONG_YING, dongPrimaryRatioLists, dongJuniorRatioLists, dongHighRatioLists, AllRatios);
        setSchoolRatios(StatisticalConstant.LI_JIN, liPrimaryRatioLists, liJuniorRatioLists, liHighRatioLists, AllRatios);
        setSchoolRatios(StatisticalConstant.KEN_LI, kenPrimaryRatioLists, kenJuniorRatioLists, kenHighRatioLists, AllRatios);
        setSchoolRatios(StatisticalConstant.GUANG_RAO, guangPrimaryRatioLists, guangJuniorRatioLists, guangHighRatioLists, AllRatios);
        setSchoolRatios(StatisticalConstant.HE_KOU, hePrimaryRatioLists, heJuniorRatioLists, heHighRatioLists, AllRatios);
        setSchoolRatios(StatisticalConstant.JING_JI_NEW, jingPrimaryRatioLists, jingJuniorRatioLists, jingHighRatioLists, AllRatios);
        setSchoolRatios(StatisticalConstant.NONG_GAO_NEW, nongPrimaryRatioLists, nongJuniorRatioLists, nongHighRatioLists, AllRatios);
        setSchoolRatios(StatisticalConstant.SHI_ZHI, shiPrimaryRatioLists, shiJuniorRatioLists, shiHighRatioLists, AllRatios);

        return AllRatios;
    }

    /**
     * 根据县区名称得到小学/初中/高中师生比
     * @param primaryRatioLists
     * @param juniorRatioLists
     * @param highRatioLists
     * @param baseInfo
     */
    private void setCityRatios(List<Map<String, Object>> primaryRatioLists, List<Map<String, Object>> juniorRatioLists, List<Map<String, Object>> highRatioLists, TeacherStudentRatioVo baseInfo) {
        Map<String,Object> map = new HashMap<>();
        if(baseInfo.getLearnType().equals(StatisticalConstant.PRIMARY_SCHOOL)){
            map.put("小学城乡统一编制标准", StatisticalConstant.PRIMARY_SCHOOL_BASE);
            handExceptionNumbers(primaryRatioLists, baseInfo, map);
        }else if(baseInfo.getLearnType().equals(StatisticalConstant.JUNIOR_SCHOOL)){
            map.put("初中城乡统一编制标准", StatisticalConstant.JUNIOR_SCHOOL_BASE);
            handExceptionNumbers(juniorRatioLists, baseInfo, map);
        }else{
            map.put("高中城乡统一编制标准", StatisticalConstant.HIGH_SCHOOL_BASE);
            handExceptionNumbers(highRatioLists, baseInfo, map);
        }
    }

    /**
     * 处理得到学校名称/师生比，将不是数字的比例设置为零
     * @param ratioLists
     * @param baseInfo
     */
    private void handExceptionNumbers(List<Map<String, Object>> ratioLists, TeacherStudentRatioVo baseInfo, Map<String,Object> map) {
        map.put("学校名称", baseInfo.getSchoolName());
        String percentage = WilliamUtil.getSchoolPercentage(baseInfo.getTotalStudent(), baseInfo.getTotalNumberStaff());
        if (!percentage.contains(".")){
            percentage = "0";
        }
        map.put("师生比", percentage);
        ratioLists.add(map);
    }

    /**
     * 获取各县区的小学/初中/高中，师生比情况
     * @param location
     * @param primaryRatioLists
     * @param juniorRatioLists
     * @param highRatioLists
     * @param allRatios
     */
    private void setSchoolRatios(String location, List<Map<String, Object>> primaryRatioLists, List<Map<String, Object>> juniorRatioLists, List<Map<String, Object>> highRatioLists, Map<String,Object> allRatios) {
        Map<String, Object> map = new HashMap<>();
        map.put("小学", primaryRatioLists);
        map.put("初中", juniorRatioLists);
        map.put("高中", highRatioLists);
        allRatios.put(location, map);
    }


    /**
     * 根据字典类型获取字典值
     * @param schoolType
     * @return
     */
    private String getSchoolType(String schoolType) {
        return sysBaseAPI.getSchoolType(schoolType);
    }

    /** 功能描述:实例化map
     *
     * @vison: 1.0.0
     * @Author: WilliamYe
     * @Date: 2020/11/25 19:22
     */
    private Map<String, Object> getMapByAge(String age) {
        Map<String, Object> map = new HashMap<>();
        map.put("年龄段",age);
        return map;
    }

    /** 功能描述:实例化map
     *
     * @vison: 1.0.0
     * @Author: WilliamYe
     * @Date: 2020/11/25 20:41
     */
    private Map<String, Object> getMapByQua(String qualification) {
        Map<String, Object> map = new HashMap<>();
        map.put("学历",qualification);
        return map;
    }


    /**
     * 测试多线程 - 这里进行标注为异步任务，在执行此方法的时候，会单独开启线程来执行(并指定线程池的名字)
     * @param user
     * @return
     */
    @Override
    @Async("taskExecutor")
    public CompletableFuture<String> findUser(String user) throws InterruptedException {
        log.info("Looking up " + user);
        String url = String.format("https://api.github.com/users/%s", user);
        // Artificial delay of 3s for demonstration purposes
        Thread.sleep(3000L);
        return CompletableFuture.completedFuture(url);
    }

}
